Import('RTT_ROOT')
Import('rtconfig')
from building import *

# The set of source files associated with this SConscript file.
dfs = Split("""
src/dfs.c
src/dfs_fs.c
src/dfs_file.c
src/dfs_posix.c
""")

# DFS-ELMFAT options
elmfat = Split("""
filesystems/elmfat/dfs_elm.c
filesystems/elmfat/ff.c
""")

# DFS-ROMFS options
romfs = Split("""
filesystems/romfs/dfs_romfs.c
""")
if not GetDepend('DFS_ROMFS_ROOT'):
    romfs = romfs + Split('filesystems/romfs/romfs.c')

# DFS-DeviceFS options
devfs = Split("""
filesystems/devfs/devfs.c
filesystems/devfs/console.c
""")

# DFS-YAFFS2 options
yaffs2_main = Split("""
filesystems/yaffs2/direct/yaffscfg.c
filesystems/yaffs2/direct/yaffs_fileem.c
filesystems/yaffs2/direct/yaffsfs.c
filesystems/yaffs2/direct/dfs_yaffs2.c
""")

yaffs2_comm = Split("""
filesystems/yaffs2/yaffs_ecc.c
filesystems/yaffs2/yaffs_guts.c
filesystems/yaffs2/yaffs_packedtags1.c
filesystems/yaffs2/yaffs_tagscompat.c
filesystems/yaffs2/yaffs_packedtags2.c
filesystems/yaffs2/yaffs_tagsvalidity.c
filesystems/yaffs2/yaffs_nand.c
filesystems/yaffs2/yaffs_checkptrw.c
filesystems/yaffs2/yaffs_qsort.c
""")

nfs = Split('''
filesystems/nfs/mount_clnt.c
filesystems/nfs/mount_xdr.c
filesystems/nfs/nfs_clnt.c
filesystems/nfs/nfs_xdr.c
filesystems/nfs/dfs_nfs.c
filesystems/nfs/rpc/auth_none.c
filesystems/nfs/rpc/clnt_generic.c
filesystems/nfs/rpc/clnt_udp.c
filesystems/nfs/rpc/rpc_prot.c
filesystems/nfs/rpc/pmap.c
filesystems/nfs/rpc/xdr.c
filesystems/nfs/rpc/xdr_mem.c
''')

uffs = Split('''
filesystems/uffs/src/uffs/uffs_badblock.c
filesystems/uffs/src/uffs/uffs_blockinfo.c
filesystems/uffs/src/uffs/uffs_buf.c
filesystems/uffs/src/uffs/uffs_debug.c
filesystems/uffs/src/uffs/uffs_device.c
filesystems/uffs/src/uffs/uffs_ecc.c
filesystems/uffs/src/uffs/uffs_fd.c
filesystems/uffs/src/uffs/uffs_find.c
filesystems/uffs/src/uffs/uffs_flash.c
filesystems/uffs/src/uffs/uffs_fs.c
filesystems/uffs/src/uffs/uffs_init.c
filesystems/uffs/src/uffs/uffs_mem.c
filesystems/uffs/src/uffs/uffs_mtb.c
filesystems/uffs/src/uffs/uffs_pool.c
filesystems/uffs/src/uffs/uffs_public.c
filesystems/uffs/src/uffs/uffs_tree.c
filesystems/uffs/src/uffs/uffs_utils.c
filesystems/uffs/src/uffs/uffs_version.c
filesystems/uffs/dfs_uffs.c
''')

others = '''
filesystems/uffs/dfs_nand_if.c
filesystems/uffs/uffs_ext.c
filesystems/uffs/flash/k9f2g08.c
filesystems/uffs/flash/nand_ids.c
'''

src_local = dfs
# The set of source files associated with this SConscript file.
path = [RTT_ROOT + '/components/dfs', RTT_ROOT + '/components/dfs/include']

if GetDepend('RT_USING_DFS_YAFFS2'):
    src_local = src_local + yaffs2_main + yaffs2_comm
    path = path + [RTT_ROOT + '/components/dfs/filesystems/yaffs2', RTT_ROOT + '/components/dfs/filesystems/yaffs2/direct']

if GetDepend('RT_USING_DFS_ELMFAT'):
    if GetDepend('RT_DFS_ELM_USE_LFN'):
        elmfat += ['filesystems/elmfat/option/cc936.c']
    src_local = src_local + elmfat

if GetDepend(['RT_USING_DFS_NFS', 'RT_USING_LWIP']):
    src_local = src_local + nfs
    path = path + [RTT_ROOT + '/components/dfs/filesystems/nfs']

if GetDepend('RT_USING_DFS_ROMFS'):
    src_local = src_local + romfs
    path = path + [RTT_ROOT + '/components/dfs/filesystems/romfs']

if GetDepend('RT_USING_DFS_DEVFS'):
    src_local = src_local + devfs
    path = path + [RTT_ROOT + '/components/dfs/filesystems/devfs']

if GetDepend('RT_USING_DFS_UFFS'):
    src_local = src_local + uffs
    path = path + [RTT_ROOT + '/components/dfs/filesystems/uffs/src/inc', RTT_ROOT + '/components/dfs/filesystems/uffs', RTT_ROOT + '/components/dfs/filesystems/uffs/flash']

group = DefineGroup('Filesystem', src_local, depend = ['RT_USING_DFS'], CPPPATH = path)

Return('group')
